package com.carboy.launch.utils;

import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.widget.Toast;

import com.carboy.launch.TtsManager;

/***
 * @author James
 * @Package com.huixin.carnav.utils
 * @Title: JwdLog.java
 * @Description 开发测试专用管理 Log，语音播报，toast工具类，注意正式版本要在Appliaction均要设置false，测试设置true
 * @date 2015-10-29
 * @version 1.0
 * 
 */
public class JwdLog {

	public static boolean isJwdLog = false;// 是否需要打印bug
	public static boolean isJwdPlay = false;// 是否需要语音播报
	public static boolean isJwdToast = false;// 是否需要toast
	private static final String TAG = "jwd";

	/* cannot be instantiated */
	private JwdLog() {
		throw new UnsupportedOperationException("cannot be instantiated");
	}

	/**
	 * 
	 * @author James
	 * @Description 设置是否打印Log
	 * @param isLog
	 */
	public static void setLog(boolean isLog) {
		isJwdLog = isLog;
	}

	/***
	 * 
	 * @author James
	 * @Description 设置是否语音播报测试
	 * @param isPlayVoice
	 */
	public static void setPlayVoice(boolean isPlayVoice) {
		isJwdPlay = isPlayVoice;
	}

	/**
	 * 
	 * @author James
	 * @Description 设置是否Toast
	 * @param isToast
	 */
	public static void setToast(boolean isToast) {
		isJwdToast = isToast;
	}

	// 下面四个是默认tag的函数
	public static void i(String msg) {
		if (isJwdLog)
			Log.i(TAG, msg);
	}

	public static void d(String msg) {
		if (isJwdLog)
			Log.d(TAG, msg);
	}

	public static void e(String msg) {
		if (isJwdLog)
			Log.e(TAG, msg);
	}

	public static void v(String msg) {
		if (isJwdLog)
			Log.v(TAG, msg);
	}

	// 下面是传入自定义tag的函数
	public static void i(String tag, String msg) {
		if (isJwdLog)
			Log.i(tag, msg);
	}

	public static void d(String tag, String msg) {
		if (isJwdLog)
			Log.i(tag, msg);
	}

	public static void e(String tag, String msg) {
		if (isJwdLog)
			Log.i(tag, msg);
	}

	public static void v(String tag, String msg) {
		if (isJwdLog)
			Log.i(tag, msg);
	}

	/**
	 * 
	 * @author James
	 * @Description 语音播报测试
	 * @param mContext
	 * @param playText
	 */
	public static void playVoice(Context mContext, String playText) {
		if (isJwdPlay) {
			TtsManager.getInstance(mContext).playText2(playText);
		}
	}

	/**
	 * 
	 * @author James
	 * @Description 用于AIDL发送广播播报语音
	 * @param mContext
	 * @param playText
	 */
	public static void playVoiceForAidl(Context mContext, String playText) {
		if (isJwdPlay) {
			Intent mIntentt = new Intent(
					"android.intent.action.VOICE.BROADCAST");
			mIntentt.putExtra("text", playText);
			mContext.sendBroadcast(mIntentt);
		}
	}

	/**
	 * 
	 * @author James
	 * @Description Toast 长时
	 * @param mContext
	 * @param toastText
	 */
	public static void toastLen(Context mContext, String toastText) {
		if (isJwdToast) {
			Toast.makeText(mContext, toastText, Toast.LENGTH_LONG).show();
		}
	}

	/**
	 * 
	 * @author James
	 * @Description Toast 短时
	 * @param mContext
	 * @param toastText
	 */
	public static void toastShort(Context mContext, String toastText) {
		if (isJwdToast) {
			Toast.makeText(mContext, toastText, Toast.LENGTH_LONG).show();
		}
	}
}
